From: emellor@ewan Date: Thu, 6 Oct 2005 10:09:14 +0000 (+0100) Subject: Rename all dying domains to be prefixed with Zombie. This allows a new domain X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~16763^2~27 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22?a=commitdiff_plain;h=0465a697d376041770cfa3a1d4f97b84eb5cb8ff;p=xen.git Rename all dying domains to be prefixed with Zombie. This allows a new domain to be created with the same name, fixing the race condition inside XendDomain that caused bug #278. Move the state_set(TERMINATED) call onto the end of cleanupDomain rather than destroyDomain, so that this flag is set when XendDomain cleans up a domain that was killed without going through Xend. Remove is_terminated, as this check is no longer necessary, since we are using Zombie prefixes instead. Signed-off-by: Ewan Mellor --- diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index 416e17914b..19814c6bdc 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -97,6 +97,7 @@ SHUTDOWN_TIMEOUT = 30 DOMROOT = '/local/domain/' VMROOT = '/vm/' +ZOMBIE_PREFIX = 'Zombie-' xc = xen.lowlevel.xc.new() xroot = XendRoot.instance() @@ -997,8 +998,6 @@ class XendDomainInfo: dominfo = domain_by_name(name) if not dominfo: return - if dominfo.is_terminated(): - return if self.domid is None: raise VmError("VM name '%s' already in use by domain %d" % (name, dominfo.domid)) @@ -1100,6 +1099,14 @@ class XendDomainInfo: except: log.exception("Removing domain path failed.") + try: + if not self.info['name'].startswith(ZOMBIE_PREFIX): + self.info['name'] = self.generateZombieName() + except: + log.exception("Renaming Zombie failed.") + + self.state_set(STATE_VM_TERMINATED) + def cleanupVm(self): """Cleanup VM resources. Idempotent. Nothrow guarantee.""" @@ -1123,24 +1130,16 @@ class XendDomainInfo: log.debug("XendDomainInfo.destroyDomain(%s)", str(self.domid)) self.cleanupDomain() - + try: if self.domid is not None: xc.domain_destroy(dom=self.domid) except: log.exception("XendDomainInfo.destroy: xc.domain_destroy failed.") - self.state_set(STATE_VM_TERMINATED) - ## private: - def is_terminated(self): - """Check if a domain has been terminated. - """ - return self.state == STATE_VM_TERMINATED - - def release_devices(self): """Release all domain's devices. Nothrow guarantee.""" @@ -1353,6 +1352,18 @@ class XendDomainInfo: n += 1 + def generateZombieName(self): + n = 0 + name = ZOMBIE_PREFIX + self.info['name'] + while True: + try: + self.check_name(name) + return name + except VmError: + n += 1 + name = "%s%d-%s" % (ZOMBIE_PREFIX, n, self.info['name']) + + def configure_bootloader(self): if not self.info['bootloader']: return